﻿#include "log_appender.h"

namespace breaking
{
	log_appender::log_appender() :m_roll_type(FILE_ROLL_DAY), m_max_file_size(0)
	{
	}

	log_appender::~log_appender()
	{
	}

	bool log_appender::open()
	{
		std::lock_guard<std::mutex> lock(m_mutex);
		return do_open();
	}

	void log_appender::close()
	{
		std::lock_guard<std::mutex> lock(m_mutex);
		do_close();
	}

	bool log_appender::append(const log_event& event)
	{
		std::lock_guard<std::mutex> lock(m_mutex);
		return do_append(event);
	}

	void log_appender::set_roll_type(file_roll_type type)
	{
		m_roll_type = type;
	}

	size_t log_appender::get_roll_type() const
	{
		return m_roll_type;
	}

	void log_appender::set_max_file_size(size_t size)
	{
		m_max_file_size = size;
	}

	size_t log_appender::get_max_file_size() const
	{
		return m_max_file_size;
	}
}